<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@include file="/pub/import.jsp"%>
<%
    int projectId = RequestUtil.getIntParameter(request, "projectID", 0);
    int recid = RequestUtil.getIntParameter(request, "recid", 0);
    String[] idArr = request.getParameterValues("selectedID");
    if(idArr==null || idArr.length==0) {
      out.println("<script>alert(\"当前无数据或者请选择要传递的质量控制点\");history.go(-1);</script>");
    }
    else
    {
	    String ids = Arrays.toString(idArr);
	    ids = ids.substring(1,ids.length()-1);
	    List<ProjectItems> list = ProjectItemsHandler.getProjectItemsByIds(ids);
	    String itemTitle = "";
	    String grade = "";
	    String qtype = "";
	    String descUrl="";
	    for(int i=0; i<list.size(); i++) {
	      ProjectItems item = list.get(i);
	      if(!itemTitle.equals("")) itemTitle += "|";
	      if(!grade.equals("")) grade += "|";
	      if(!qtype.equals("")) qtype += "|";
	      if(!descUrl.equals("")) descUrl +="|";
	      itemTitle += item.getScoreItem().getItemName();
	      grade += item.getScore();
	      if(item.getTopCateId()==3)
	      {
	      	qtype += "质量实体";  
	      }
	      else
	      {
	      	qtype += "质量行为";
	      }
	      descUrl +=   "http://210.75.208.134:8080/services/getScoreItemDesc.jsp?itemID="+item.getScoreItem().getId();
	    }
	    String str = HttpUtil.send("http://192.168.14.34/inputrec.aspx", "projectID=" + projectId
	        + "&recid=" + recid + "&itemTitle=" + URLEncoder.encode(itemTitle,"utf-8") + "&grade=" + grade + "&qtype=" +URLEncoder.encode(qtype,"utf-8")+ "&descUrl=" +descUrl+ "&key=DALFM13ASA42D", "GET");
	     if(str.equals("0"))
	     {
	     	out.println("发送成功，<a href=\"getProjectDetail.jsp?projectID="+projectId+"&recid="+recid+"\">继续查找</a>");
	     }
	     else
	     {
	     	out.println("数据传输异常,返回代码："+str+"；<a href=\"getProjectDetail.jsp?projectID="+projectId+"&recid="+recid+"\">重新查找</a>");
	     }
    }
%>